import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {

  public title2 = ' 我是一个title，获得数据';
  // 定义数组

  public arr = ['111', '222', '333'];

  public list: any[string] = ['我是第一个新闻', '22', '我是第三个新闻'];

  public items: Array<number> = [11, 22, 33];

  public archive: Array<string> = ['11', '22', '33'];

  public student: object = {
    username: '张三',
    age: 19
  };

  public msg: any;

  // 数组对象
  public userOneList: any[] = [{username: 'test', age: 18}, {username: 'test2', age: 183}];

  // 定义嵌套数组

  public cars: any[] = [
    {
      catName: '宝马',
      list: [{
        title: 'x1',
        price: '30万'
      },
        {
          title: 'x2',
          price: '30万'
        }]
    },
    {
      catName: '奥迪',
      list: [{
        title: 'q1',
        price: '40万'
      },
        {
          title: 'q2',
          price: '40万'
        }]
    }

  ];

  public listNews: any[] = [
    {
       title: '我是新闻1',
    },
    {
      title: '我是新闻2',
    },

    {
      title: '我是新闻3',
    }
  ];

  public inputValue2 =  '这是默认值';
  public flag = true;

  public orderStatus = 1;

  public attr = 'red';

  public today: any = new Date();
  constructor() {
    this.msg = '构造赋值';
    console.log(this.today);
  }

  public content: any = '<h2>我是一个html标签</h2>';
  ngOnInit() {
  }

  // 方法与方法之间不需要加逗号
  run() {
    alert(' 执行一个自定义的方法 ');
  }

  getData() {
    alert(this.title2);
  }

  setData() {
    this.title2 = '我是一个改变后的值';
  }

  keydown(e) {

    console.log(e);
    console.log(e.target);
  }

  changeValue() {
    this.inputValue2 = '我是改变后的值';
  }
}
